<template>
  <div>
    <FormPanel  ref="formPanel"
        :list="initForm"
        :cols="1"
        :labelWidth="100"
        :isSubmitBtn="false"
        @formChange="formChangeHandle"
        class="mtop"
     />
     <div class="dialogBottmView">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button @click="saveDialog" type="primary">保 存</el-button>
    </div>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
export default {
  mixins: [dictionary],
  data() {
    return {
      initForm : this.initFormFun()
    };
  },
  methods: {
    //初始化数据
    init(data){
     if(data.type==='edit'){
       this.initForm.forEach(x => {
          x.initialValue = data.row[x.fieldName];
        });
      }
    },
    //搜索数据
    initFormFun(){
        return [{
              type: 'INPUT',
              label: '岗位代码',
              fieldName: 'field1',
              placeholder: '请输入',
              initialValue: '',
              rules: [{
                required: true,
                message: '必填',
                trigger: 'blur'
              }]
            },{
              type: 'INPUT',
              label: '岗位名称',
              fieldName: 'field01',
              placeholder: '请输入',
              initialValue: '',
              rules: [{
                required: true,
                message: '必填',
                trigger: 'blur'
              }]
            },
            {
              type: 'SELECT',
              label: '是否培训岗位',
              fieldName: 'field2',
              placeholder: '请选择',
              initialValue: "",
              itemList: this.createDictList('1008'),
              rules: [{
                required: true,
                message: '必填',
                trigger: 'change'
              }]
            },
            {
              type: 'SELECT',
              label: '启用标志',
              fieldName: 'field3',
              placeholder: '请选择',
              initialValue: "",
              itemList: this.createDictList('1008'),
              rules: [{
                required: true,
                message: '必填',
                trigger: 'change'
              }]
            },
            {
              type: 'SELECT',
              label: '关键提醒',
              fieldName: 'field4',
              placeholder: '请选择',
              initialValue: "",
              itemList: this.createDictList('1008')
            },
            {
              type: 'TEXT_AREA',
              label: '岗位描述',
              fieldName: 'field10',
              rows: 3,
              initialValue: '',
              placeholder: '请输入'
            }
          ]
    },
    formChangeHandle(val){
      console.log(val)
      this.$emit('close', {visible:false,refresh:true});
    },
    //保存
    saveDialog(val){
       this.$refs.formPanel.SUBMIT_FORM()
    },
    //取消操作
    closeDialog(){
      this.$emit('close', {visible:false,refresh:false});
    }
  },
}
</script>